//  时间格式化为 2019-08-01 22:00:00
export default {
  install(Vue, options) {
    Vue.prototype.formatTime = function(row, column) {
      if (!column) {
        return ''
      }
      var value = row[column.property]
      if (typeof (value) === 'undefined') {
        return ''
      }
      const date = new Date(value)
      var time = new Date(date)
      var y = time.getFullYear()
      var m = time.getMonth() + 1
      var d = time.getDate()
      var h = time.getHours()
      var mm = time.getMinutes()
      var s = time.getSeconds()
      var result = y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s)
      return result
    }
  }
}

function add0(m) {
  return m < 10 ? '0' + m : m
}
